#ifndef __APP_MSG_H
#define __APP_MSG_H

#ifdef __cplusplus
extern "C" {
#endif

#include "type.h"

#define MAX_UART_DATA_LEN 128

typedef enum
{
    CMD_SEND_ALLINFO = 0x01,
    CMD_SEND_SETTING = 0x02,
    CMD_SEND_ALARM   = 0x03,
}CTRL_CMD;

typedef struct
{
  unsigned char sign1;//帧头
  unsigned char cmd;  //命令字 
  unsigned short len; //数据长度
  unsigned char data[];
}__attribute__((__packed__)) MSG_HEADER;
#define MSG_HEADER_LEN sizeof(MSG_HEADER)

//命令字 [0x01 数据上报; 0x02 设置参数上报; 0x03 报警信息上报]
typedef struct{
  int heart;          //心率值
  int spo;            //血氧值
  float temperature;  //体温值
  float pressure;     //血压值
  float angle;        //最大角
  float Longitude;    //经度
  float Latitude;     //纬度
}__attribute__((__packed__))ALLINFO_MSG;
#define ALLINFO_MSG_LEN sizeof(ALLINFO_MSG)

typedef struct{
  unsigned char max_angle;//最大角度阈值
  unsigned char max_heart;//最大心率阈值
  unsigned char max_tempe;//最大温度阈值
  unsigned char max_press;//最大血压阈值
}__attribute__((__packed__))SET_MSG;
#define SET_MSG_LEN sizeof(SET_MSG)

typedef struct{
  unsigned char alarm_angle;  //跌倒报警
  unsigned char alarm_heart;  //心率报警
  unsigned char alarm_tempe;  //温度报警
  unsigned char alarm_press;  //血压报警
}__attribute__((__packed__))ALARM_MSG;
#define ALARM_MSG_LEN sizeof(ALARM_MSG)

typedef struct{
  unsigned char sign1;//帧头
  unsigned char cmd;  //命令字【1：温度上限 2：温度下限 3：心率上限 4：心率下限】
  unsigned char data; //数据
  unsigned char check;//校验位
}__attribute__((__packed__))SET_REC_MSG;
#define SET_REC_MSG_LEN sizeof(SET_REC_MSG)


void WIFI_Recive_MsgHandler(u8 *data,u16 len);
void WIFI_TIMER_HANDER(void);

#ifdef __cplusplus
}
#endif

#endif
